package com.dimples.dd.system.convert;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dimples.dd.common.pojo.PageResult;
import com.dimples.dd.system.model.bo.NoticeBO;
import com.dimples.dd.system.model.entity.SystemNoticeDO;
import com.dimples.dd.system.model.form.NoticeForm;
import com.dimples.dd.system.model.vo.NoticeDetailVO;
import com.dimples.dd.system.model.vo.NoticePageVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * 通知公告对象转换器
 *
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/12/29
 */
@Mapper(componentModel = "spring")
public interface NoticeConverter {


    @Mappings({
            @Mapping(target = "targetUserIds", expression = "java(cn.hutool.core.util.StrUtil.split(entity.getTargetUserIds(),\",\"))")
    })
    NoticeForm entity2Form(SystemNoticeDO entity);

    @Mappings({
            @Mapping(target = "targetUserIds", expression = "java(cn.hutool.core.collection.CollUtil.join(formData.getTargetUserIds(),\",\"))")
    })
    SystemNoticeDO form2Entity(NoticeForm formData);

    NoticePageVO entityPage2Vo(NoticeBO bo);

    Page<NoticePageVO> entityPage2Vo(Page<NoticeBO> noticePage);

    NoticeDetailVO bo2DetailVO(NoticeBO noticeBO);

    PageResult<NoticePageVO> boPage2Vo(PageResult<NoticeBO> pageResult);
}
